/*
 * @Author: your name
 * @Date: 2021-12-08 09:26:35
 * @LastEditTime: 2022-01-09 21:25:39
 * @LastEditors: Please set LastEditors
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: \lliyuwei2\admin\src\router\index.tsx
 */
import { BrowserRouter } from "react-router-dom";
import { useEffect, useState } from "react";
import RouterView from "./RouterView";
import visitorRouter from "./route/visitor";
import adminRouter from "./route/admin";
//获取用户信息
const Router = () => {
  const userData = window.sessionStorage.getItem("userData");
  const [role, setRole] = useState("");
  useEffect(() => {
    if (userData) {
      setRole(JSON.parse(userData).identity);
    } else {
      setRole("访客");
    }
  });
  return <BrowserRouter>{role === "管理员" ? <RouterView routes={adminRouter} /> : <RouterView routes={visitorRouter} />}</BrowserRouter>;
};
export default Router;
